<?php

require_once("Validate.php");
require_once("String.php");

	class AllTest {
		
		public function Test(){
		
			$testMessage = array();
			
			$email = "Email";
			$date = "Date";
			$pers = "PersNo";
			$pass = "Password";
			$number = "Number";				
			
			$correctEmail= array('simon@student.lnu.se', 'simon.student@lnu.se', 'simon@student.com');
			$inCorrectEmail = array('simon.student.lnu.se', 'simon@lnu se', 'simon@student', 'simon');
			
			$correctPers = array('19840228-8351', '198402288351', '840228-8351', '8402288351');
			$inCorrectPers = array('1234567', '12345678911', 'ABCDEFGH', 'ABCDEFGHIJKLMN', '987612');	
					
			$correctDate = array('1999-10-01', '99-10-01', '991001');
			$inCorrectDate = array('19991025', 'ABCDE', 'ABCDEFGH', '1999-13-20', '991245');
			
			$correctPass = array('123456', 'ABCDEFGH', 'asdf65438');
			$inCorrectPass = array('TRE', '12345', '/&%¤');
			
			$correctNo = array('1234567');
			$inCorrectNo = array('aABcdf');														
			
			$testMessage[$email] = self::Tester($email, $correctEmail, $inCorrectEmail, String::NO_EMAIL, String::EMAIL);
			$testMessage[$pers] = self::Tester($pers, $correctPers, $inCorrectPers, String::NO_PERS, String::PERS);
			$testMessage[$date] = self::Tester($date, $correctDate, $inCorrectDate, String::NO_DATE, String::DATE);
			$testMessage[$pass] = self::Tester($pass, $correctPass, $inCorrectPass, String::NO_PASS, String::PASS);
			$testMessage[$number] = self::Tester($number, $correctNo, $inCorrectNo, String::NO_NUMBER, String::NUMBER);
			
			if(isset($testMessage)){
				return $testMessage;
			}
		}
		
		public function Tester($functionName, $correctArray, $inCorrectArray, $messageNo, $messageYes){
		
			$val = new Validate();

			$ArrayMessage = array();
								
			for($i = 0; $i < count($correctArray); $i++){
				
				if(!$val->$functionName($correctArray[$i])){
					$ArrayMessage[] = $correctArray[$i] . $messageNo;
				}
				
			}
			
			for($i = 0; $i < count($inCorrectArray); $i++){
				
				if($val->$functionName($inCorrectArray[$i])){
					$ArrayMessage[] = $inCorrectArray[$i] . $messageYes;
				}
				
			}
			
			if (isset($ArrayMessage)){
				return $ArrayMessage;
			}		
		}
					
	}
